package io.renren.controller;

import io.renren.annotation.Login;
import io.renren.annotation.LoginUser;
import io.renren.common.constant.Constant;
import io.renren.common.entity.XlsCartEntity;
import io.renren.common.entity.XlsUserEntity;
import io.renren.common.page.PageData;
import io.renren.common.utils.Result;
import io.renren.common.validator.AssertUtils;
import io.renren.common.validator.ValidatorUtils;
import io.renren.common.validator.group.AddGroup;
import io.renren.common.validator.group.DefaultGroup;
import io.renren.common.validator.group.UpdateGroup;
import io.renren.dto.XlsCartDTO;
import io.renren.service.XlsCartService;
import io.renren.utils.AppResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;


/**
 * 购物车
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0 2020-04-11
 */
@RestController
@RequestMapping("api/xlscart")
@Api(tags="购物车")
public class XlsCartController {
    @Autowired
    private XlsCartService xlsCartService;

    /**
     * 用户添加购物车
     * @param xlsCartEntity
     * @return
     */
    @PostMapping( "/addCarts")
    @ApiOperation(value="添加购物车")
    public AppResult addCarts(XlsCartEntity xlsCartEntity){
        return xlsCartService.addcarts(xlsCartEntity);

    }


    /**
     * 根据用户Id查询购物车
     * @param xlsCartEntity
     * @return
     */
    @PostMapping( "/getCartInfo")
    @ApiOperation(value="查询购物车")
    public AppResult getCartInfo(XlsCartEntity xlsCartEntity){
        return xlsCartService.getCartInfo(xlsCartEntity);
    }

    /**
     * 修改购物车
     * @return
     */
    @PostMapping( "/updateCart")
    @ApiOperation(value="修改购物车")
    public AppResult updateCart(XlsCartEntity xlsCartEntity){
        return xlsCartService.updateCart(xlsCartEntity);
    }

    /**
     * 删除购物车
     * @param ids
     * @return
     */
    @PostMapping( "/remove")
    @ApiOperation(value="删除购物车")
    public AppResult remove(String ids){
        return xlsCartService.remove(ids);
    }

    @RequestMapping("/gotoPay")
    @ApiOperation(value="购物车去结算")
    public AppResult gotoPay(Long userId){
        return xlsCartService.gotoPay(userId);
    }


}